const userTokenName = 'hmToken'
const channelName = 'hmToken'
const searchName = 'searchListLocal'

export function getToken() {
  // vuex的state的获取的值不是响应式  手动删除token  vuex的token没有更新
  // 只有 mutation 改变token值 响应变化 更新token
  return JSON.parse(localStorage.getItem(userTokenName)) || {}
}
export function setToken(token) {
  localStorage.setItem(userTokenName, JSON.stringify(token))
}
export function removeToken() {
  localStorage.removeItem(userTokenName)
}
export function setLocalchannel(channelList) {
  localStorage.setItem(channelName, JSON.stringify(channelList))
}
export function getLocalchannel() {
  return JSON.parse(localStorage.getItem(channelName))
}
export function getSearchList() {
  return JSON.parse(localStorage.getItem(searchName)) || []
}
export function setSearchList(searchList) {
  localStorage.setItem('searchListLocal', JSON.stringify(searchList))
}
